package com.eascs.p2p.admin.manager.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.eascs.p2p.admin.manager.ISelectDataManager;
import com.eascs.p2p.common.dao.BaseDao;

@Repository
public class SelectDataManagerImpl extends BaseDao implements ISelectDataManager {
	

	@Override
	public List<Object[]> getDataSouce(String dataSouceType, String dataSouceFrom) {

		List<Object[]> dataSouceList = new ArrayList<>();
		List<Object> listParams = new ArrayList<Object>();
		StringBuffer sql = new StringBuffer("SELECT item.item_code,item.item_name FROM p2p_datadic_item item");
		sql.append(" where item.dd_no = (select dic.id  from 	p2p_datadic dic  where 1=1");
		if (dataSouceType != null && !"".equals(dataSouceType)) {
			sql.append(" and dd_code= ? )");
			listParams.add(dataSouceType);
		}
		if (dataSouceFrom != null && !"".equals(dataSouceFrom)) {
			sql.append(" and parent_code= ?");
			listParams.add(dataSouceFrom);
		}
		sql.append(" order by  item_code  asc ");
		dataSouceList = this.findObjectsList(sql.toString(), listParams.toArray());
		return dataSouceList;
	}

}
